package com.example.dubbonacosuserprovider.controller;

import api.entity.User;
import api.service.UserService2;
import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @NacosValue(value = "${nacosuser.name}",autoRefreshed = true)
    private String name;
    @Autowired
    private UserService2 userService2;

    @GetMapping("/save")
    public String SaveUser(User user){
        userService2.SaveUser(user);
        System.out.println(user);
        return  "success";
    }

    @GetMapping("/getUser")
    public String nacosuser(){
        return name;
    }
}
